/*************************************************************************
	> File Name: complex.cpp
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 五  1/ 7 11:48:31 2022
 ************************************************************************/

#include <iostream>
using namespace std;

#define EPISON 1e-7

class ComplexNum {
public:
    ComplexNum(double a, double b);
    ComplexNum operator+(const ComplexNum &z);
    ComplexNum operator-(const ComplexNum &z);
    ComplexNum operator*(const ComplexNum &z);
    ComplexNum operator/(const ComplexNum &z);
    ComplexNum &operator=(const ComplexNum &z);
private:
    double a, b;
    friend ostream &operator<<(ostream &out, const ComplexNum &z);
};

ComplexNum::ComplexNum(double a, double b) : a(a), b(b) {}

ComplexNum ComplexNum::operator+(const ComplexNum &z) {
    ComplexNum temp(this->a + z.a, this->b + z.b);
    return temp;
}

ComplexNum ComplexNum::operator-(const ComplexNum &z) {
    ComplexNum temp(this->a - z.a, this->b - z.b);
    return temp;
}

ComplexNum ComplexNum::operator*(const ComplexNum &z) {
    ComplexNum temp(this->a * z.a - this->b * z.b, this->b * z.a + this->a * z.b);
    return temp;
}

ComplexNum ComplexNum::operator/(const ComplexNum &z) {
    double real = (this->a * z.a + this->b * z.b) * 1.0 / (z.a * z.a + z.b * z.b);
    double img = (this->b * z.a - this->a * z.b) * 1.0 / (z.a * z.a + z.b * z.b);
    ComplexNum temp(real, img);
    return temp;
}

ComplexNum &ComplexNum::operator=(const ComplexNum &z) {
    this->a = z.a;
    this->b = z.b;
    return *this;
}

ostream &operator<<(ostream &out, const ComplexNum &z) {
    if (z.b >= EPISON) {
        out << z.a << "+" << z.b << "i" << endl;
    } else if (z.b <= -EPISON) {
        out << z.a << z.b << "i" << endl;
    } else {
        out << z.a << endl;
    }
    return out;
}

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    ComplexNum cn1(a, b);
    ComplexNum cn2(c, d);
    cout << "cn1 = " << cn1 << "cn2 = " << cn2;

    ComplexNum cn3 = cn1 + cn2;
    cout << "cn1 + cn2 = " << cn3;

    ComplexNum cn4 = cn1 - cn2;
    cout << "cn1 - cn2 = " << cn4;

    ComplexNum cn5 = cn1 * cn2;
    cout << "cn1 * cn2 = " << cn5;

    ComplexNum cn6 = cn1 / cn2;
    cout << "cn1 / cn2 = " << cn6;

    return 0;
}
